import { Injectable } from '@nestjs/common';
import { Cron } from '@nestjs/schedule';
import { ModelType } from '@typegoose/typegoose/lib/types';
import { InjectModel } from 'nestjs-typegoose';
import { QudaobaoModel } from './mongodb/models/qudaobaoModel/qudaobaoModel';
import { LanxiModel } from './mongodb/models/lianxiModel/LanxiModel';
import { JobModel } from './mongodb/models/jobModel/Job.models';

@Injectable()
export class AppService {


  constructor(
    @InjectModel(LanxiModel) private readonly contact: ModelType<LanxiModel>,
    @InjectModel(JobModel) private readonly job: ModelType<JobModel>,
    @InjectModel(QudaobaoModel) private readonly channel: ModelType<QudaobaoModel>,
  ) { }

  @Cron('0 59 23 * * *')
  async handleCron() {

    /* 联系方式今日数据 */
    this.contact.updateMany({}, { todaynum: 0, todaycopy: 0, devnum: 0 }).then()

    /* 兼职今日数据 */
    this.job.updateMany({}, { clicktoday: 0, signuptoday: 0 }).then()

    /* 渠道今天数据 */
    this.channel.updateMany({}, { todayjihuo: 0, todayzhuce: 0, todaycopy: 0, todaybaomin: 0 ,todaytiaozhuan:0}).then()

  }

}
